package dmo3;

import java.util.Arrays;

public class Test {
    public static void sort(Student []students){
        Student tye;
        for (int i=0;i<students.length;i++){
            for (int j = 0; j <students.length-1 ; j++) {
                if ((students[j].compare(students[j+1])==1)){
                    tye=students[j];
                    students[j]=students[j+i];
                    students[j+i]=tye;
                }
            }
        }
    }
    public static void main(String[] args) {

       Student students1=new Student("小刘","123456",15,16);
       Student students2=new Student("小黄","25654",16,14);
        Student students3=new Student("小","25654",16,25);
        Student[]students={students1,students2,students3};
        for (Student s:students
             ) {
            System.out.println(s.getName()+s.getId()+"成绩"+s.getGrade()+s.getAge());

        }
        sort(students);
        for (Student s:students
        ) {
            System.out.println(s.getName()+" "+s.getId()+"成绩 "+s.getGrade()+" "+s.getAge());
        }
        }

    }

